﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;

namespace NetFramework
{
    /// <summary>
    /// 状态对象
    /// </summary>
    public class StateObject:IGuidable
    {
        /**/
        /// <summary>
        /// 缓存
        /// </summary>
        public byte[] buffer = null;
        /**/
        /// <summary>
        /// 工作插座
        /// </summary>
        public Socket workSocket = null;
        /**/
        /// <summary>
        /// 数据流
        /// </summary>
        public Stream Datastream = new MemoryStream();
        /**/
        /// <summary>
        /// 剩余大小
        /// </summary>
        public long residualSize = 0;
        /**/
        /// <summary>
        /// 数据包大小
        /// </summary>
        public long packSize = 0;
        /**/
        /// <summary>
        /// 计数器
        /// </summary>
        public int Cortrol = 0;


        private Guid _id;

        /**/
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="bufferSize">缓存</param>
        /// <param name="WorkSocket">工作的插座</param>
        public StateObject(int bufferSize, Socket WorkSocket)
        {
            buffer = new byte[bufferSize];
            workSocket = WorkSocket;

            GenID();
        }


        public Guid ID
        {
            get { return this._id; }
        }


        public void GenID()
        {
            this._id = Guid.NewGuid();
        }
    }
}
